//
//  BaseModel.m
//  UI11_豆瓣
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 蓝鸥科技.李贺. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel
- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype)modelWithDic:(NSDictionary *)dic {
    id model = [[[self class] alloc] initWithDic:dic];
    return model;
}

+ (NSMutableArray *)modelHandleWithArray:(NSArray *)array {
    NSMutableArray *dataArray = [NSMutableArray array];
    for (NSDictionary *dic in array) {
        id model = [[self class] modelWithDic:dic];
        [dataArray addObject:model];
    }
    return dataArray;
}

// kvc 容错方法(赋值方法)
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    // 当key找不到对应的属性时 表示不许要该数据
    
}

// (取值方法)不常用
- (id)valueForUndefinedKey:(NSString *)key {
    return nil;
}

@end
